package com.wlyuan.open.scanner.dao.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.wlyuan.open.scanner.application.annotation.DataScope;
import com.wlyuan.open.scanner.dao.entity.CarDO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author yuanjie
 * @since 2022-09-23
 */
public interface CarMapper extends BaseMapper<CarDO> {

    /**
     * 查询车辆
     *
     * @return
     */
    @Select("SELECT Car_ID, opt_status, Car_SN, Car_Type, Car_Length, Car_Weight, Car_Seats, Car_PurchaseTime, Car_Insurance, Car_Brand, Car_Photo, Car_CompanyID, Car_Creator, Car_InsertTime, Car_Updater, Car_UpdateTime, Car_Invalid, Car_Comments, Car_Volume, Car_Heat, Car_Model, Car_DriverCardName, Car_ProviceID, Car_CityID, Car_StartInsuranceTime, Car_ProviceName, Car_CityName, Car_PolicyHolder, Car_PolicyHolderPhone, Car_PolicyHolderEmail, Car_InsuranceType, Car_CarLengthName " +
            "FROM TMS_MCar " +
            "WHERE Car_CompanyID > 0")
    @DataScope(column = "Car_CompanyID")
    List<CarDO> list();

    @Select("SELECT Car_ID FROM TMS_MCar WHERE Car_InsertTime >= #{startTime} and Car_InsertTime <= #{endTime} ")
    List<Long> getByTime(@Param("startTime") String startTime, @Param("endTime") String endTime);

    @Select("SELECT Car_ID FROM TMS_MCar WHERE Car_CompanyID = #{tenantId} and Car_InsertTime >= #{startTime} and Car_InsertTime <= #{endTime} ")
    List<Long> getByTenantIdTime(@Param("tenantId") Long tenantId, @Param("startTime") String startTime, @Param("endTime") String endTime);

}
